//考勤
<template>
  <div class="">
    <button id="btn" @click="add">新增</button>
    <div>
      <el-table :data="attendance" border style="width: 100%">
        <el-table-column type="index" label="序号" width="180">
        </el-table-column>
        <el-table-column prop="checkworkname" label="考勤模板名称" width="180">
        </el-table-column>
        <el-table-column prop="numberofpeople" label="成员数">
        </el-table-column>
        <el-table-column prop="createpeople" label="创建人"> </el-table-column>
        <el-table-column prop="createDate" label="创建日期"> </el-table-column>
        <el-table-column prop="operation" label="操作">
          <template slot-scope="scope">
            <el-button @click="edit(scope.row)" type="text" size="small"
              >编辑</el-button
            >
            <el-button type="text" size="small" @click="open(scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <div id="page">
        <el-pagination
          align="right"
          background
          layout="prev, pager, next"
          :total="2"
          margin="10px"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      dialogVisible: false,
      attendance: [],
      checkworkname: "",
      numberofpeople: "",
      startWorkDate: "",
      createpeople: "",
      createDate: "",
      afterWorkDate: "",
     
    };
  },
  computed: {},
  watch: {},
  methods: {
    add(){
      this.$router.push('/addnew')
      
    },
    edit(row) {
      console.log(row);
      this.$router.push({
        path: "/attendanceadd",
        query: {
          name: row.checkworkname,
          start: row.startWorkDate,
          end: row.afterWorkDate,
        },
      });
    },
    open(num) {
      this.$confirm("是否确认删除该考勤模板 删除后将不可恢复", "删除确认", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          var params = new URLSearchParams();
          params.append("id", num.id);
          this.$axios
            .post("http://47.100.30.12:8080/checkwork/deleteById", params)
            .then((data) => {
              console.log(data);
            });
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    attend() {
      this.$axios
        .get("http://47.100.30.12:8080/checkwork/selectAll")
        .then((data) => {
          let userDate = data.data.data;
          if (data.data.code == 200) {
            for (let i in userDate) {
              this.attendance.push(userDate[i]);
            
            }
          }
        });
    },
    showPage(){
      this.$axios.get('http://47.100.30.12:8080/checkwork/selectForPage',{
        params:{
          page:1
        }
      })
    }
  },
  created() {},
  mounted() {
    this.attend();
    this.showPage()
  },
};
</script>
<style scoped>
#btn {
  margin-top: 20px;
  margin-bottom: 30px;
  width: 100px;
  height: 30px;
  background-color: rgb(70, 167, 247);
  color: white;
  margin-right: 20px;
  border: 0;
}
#page {
  margin-top: 20px;
}
</style>